<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
  CodeFile="Colleges.aspx.vb" Inherits="Colleges" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
    ProviderName="<%$ ConnectionStrings:VendorStatsConnectionString.ProviderName %>"
    SelectCommand="SELECT [CollegeId], [ShortName], [Name] FROM [Colleges] ORDER BY [ShortName]"
    DeleteCommand="DELETE FROM [Colleges] WHERE [CollegeId] = @CollegeId"
    InsertCommand="INSERT INTO [Colleges] ([ShortName], [Name]) VALUES (@ShortName, @Name)"
    UpdateCommand="UPDATE [Colleges] SET [ShortName] = @ShortName, [Name] = @Name WHERE [CollegeId] = @CollegeId">
    <DeleteParameters>
      <asp:Parameter Name="CollegeId" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
      <asp:Parameter Name="ShortName" Type="String" />
      <asp:Parameter Name="Name" Type="String" />
      <asp:Parameter Name="CollegeId" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
      <asp:Parameter Name="CollegeId" Type="Int32" />
      <asp:Parameter Name="ShortName" Type="String" />
      <asp:Parameter Name="Name" Type="String" />
    </InsertParameters>
  </asp:SqlDataSource>
  <br />
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CollegeId"
    DataSourceID="SqlDataSource1" Width="292px">
    <Columns>
      <asp:CommandField ShowEditButton="True" />
      <asp:BoundField DataField="CollegeId" HeaderText="CollegeId" ReadOnly="True" SortExpression="CollegeId"
        Visible="False" InsertVisible="False" />
      <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
      <asp:BoundField DataField="ShortName" HeaderText="ShortName" SortExpression="ShortName" />
    </Columns>
  </asp:GridView>
  <br />
  <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"
    DataKeyNames="CollegeId" DefaultMode="Insert" HeaderText="Add a new College" >
   <InsertItemTemplate>
      Name:
      <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
      <br />
      ShortName:
      <asp:TextBox ID="ShortNameTextBox" runat="server" Text='<%# Bind("ShortName") %>' />
      <br />
      <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
        CommandName="Insert" Text="Insert" />
      &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </InsertItemTemplate>
  </asp:FormView>
  <br />
</asp:Content>
